package com.huike.generator.service.impl;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.huike.clues.domain.SysOperLog;
import com.huike.common.core.page.OperLogPageQueryDto;
import com.huike.common.core.page.PageDomain;
import com.huike.common.core.page.PageResult;
import com.huike.common.utils.SecurityUtils;
import com.huike.generator.mapper.operLogMapper;
import com.huike.generator.service.operLogService;

import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class operLogServiceImpl implements operLogService {

    @Resource
    private operLogMapper operLogMapper;


    @Override
    public void deletedByList(List<Long> ids) {
        String username = SecurityUtils.getUsername();
        operLogMapper.deletedByList(ids,username);
    }

    @Override
    public void deletedAll() {
        String operName = SecurityUtils.getUsername();
        operLogMapper.deletedAll(operName);
    }

    @Override
    public void export() {

    }

    @Override
    public PageResult selectList(OperLogPageQueryDto dto) {
        PageHelper.startPage(dto.getPage(),dto.getPageSize());
        Map<String, Date> params = dto.getParams();
        Date beginTime = params.get("beginTime");
        Date endTime = params.get("endTime");
        String operName = SecurityUtils.getUsername();
        Page<SysOperLog> page = operLogMapper.selectList(beginTime,endTime,dto.getKeyWord(),operName);
        return new PageResult(page.getTotal(),page.getResult());
    }


}
